package com.guaju.yueshangLife.adapter;

import android.app.Activity;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.facebook.drawee.view.SimpleDraweeView;
import com.guaju.yueshangLife.R;
import com.guaju.yueshangLife.bean.MeOrder;

import java.util.List;

public class CommentInnerAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
    Context context;
    List<String> list;
    private int status = 1;


    Activity activity;
    private final LayoutInflater layoutInflater;
    private View view;

    public CommentInnerAdapter(Context context, List<String> list) {
        this.context = context;
        this.list = list;
        activity = (Activity) context;
        layoutInflater = LayoutInflater.from(context);
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int type) {
        View view = layoutInflater.inflate(R.layout.item_comment_inner, parent, false);
        InnerHolder innerHolder = new InnerHolder(view);
        return innerHolder;

    }

    //绑定
    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        InnerHolder innerHolder = (InnerHolder) holder;
        innerHolder.setContent(list.get(position));
    }

    //有多少个item？
    @Override
    public int getItemCount() {
        return list.size();
    }


    public interface OnItemClickListener {
        void onItemClick(View v, int position);

        void onItemLongClick(View v);
    }

    public CommentInnerAdapter.OnItemClickListener mOnItemClickListener;//第二步：声明自定义的接口

    //第三步：定义方法并暴露给外面的调用者
    public void setOnItemClickListener(CommentInnerAdapter.OnItemClickListener listener) {
        this.mOnItemClickListener = listener;
    }


    class InnerHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
        SimpleDraweeView sdv_inner;

        public InnerHolder(View itemView) {
            super(itemView);
            sdv_inner = itemView.findViewById(R.id.sdv_inner);
            itemView.setOnClickListener(this);

        }

        public void setContent(String str) {
            sdv_inner.setImageURI(str);
        }

        @Override
        public void onClick(View v) {
        }
    }


}
